from tortoise import fields, models

class Parameter(models.Model):
    parameter_id = fields.IntField(pk=True)
    category = fields.ForeignKeyField('models.ParameterCategory', related_name='parameters', on_delete=fields.CASCADE)
    icon = fields.TextField(description="图标", null=True)
    period_unit = fields.CharField(max_length=20, description="划分周期单位")
    period = fields.IntField(description="划分周期")
    granularity = fields.IntField(description="划分粒度")
    parameter_name = fields.CharField(max_length=100, description="参数名称")
    background = fields.CharField(max_length=100, description="背景",null=True)

    # 新增四个常量
    WIND_NEXT_24_HOURS_ID = 4
    WIND_TOMORROW_ID = 3
    RADIATION_NEXT_24_HOURS_ID = 2
    RADIATION_TOMORROW_ID = 1

    class Meta:
        table = "parameter"

    def __str__(self):
        return self.parameter_name
